<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::name('console')
    ->prefix('console')
    ->middleware(['auth:web'])
    ->group(function() {
        Route::any('/','ConsoleHomeController@home')
            ->defaults('_view','console.home')
            ->name('.home');

        Route::prefix('users')
            ->name('.users')
            ->group(function()
            {


                Route::get('users', 'UsersController@getModels')
                    ->defaults('_with_pager',10)
                    ->defaults('_with_sort',['id'=>'desc'])
                    ->defaults('_view','console.users.entities');

                Route::get('users/{id?}', 'UsersController@getModel')
                    ->defaults('_view','console.users.entity')
                    ->name('.view');
                Route::post('users/{id?}', 'UsersController@modelSave')->name('.save');

                Route::post('delete', 'UsersController@modelDeleteMulti')->name('.delete');


            });


        Route::prefix('oauth-apps')
            ->name('.oauth-apps')
            ->middleware(['can:view,"oauth_apps"'])
            ->group(function()
            {

                Route::get('entities', 'OauthAppsController@getModels')
                    ->defaults('_with_pager',10)
                    ->defaults('_with_sort',['id'=>'desc'])
                    ->defaults('_view','console.oauth_apps.entities');

                Route::get('entity/{id?}', 'OauthAppsController@getModel')
                    ->defaults('_view','console.oauth_apps.entity')
                    ->name('.view');
                //Route::post('entity/{id?}', 'OauthAppsController@modelSave')->name('.save');

                //Route::post('delete', 'OauthAppsController@modelDeleteMulti')->name('.delete');

                Route::get('login-logs', 'OauthAppsLoginLogController@getModels')
                    ->defaults('_with_pager',20)
                    ->defaults('_with_sort',['id'=>'desc'])
                    ->defaults('_view','console.oauth_apps.login_logs')
                    ->name('.login-logs');

            });


        Route::prefix('access-control')
            ->name('.access-control')
            ->middleware(['can:allow,"access_control"'])
            ->group(function()
            {

                Route::get('entities', 'AccessControlController@entities')
                    ->defaults('_with_pager',50)
                    ->defaults('_with_sort',['id'=>'desc'])
                    ->defaults('_view','console.access_control.entities')
                    ->name('.entities');

                Route::get('roles', 'AccessControlController@roles')
                    ->defaults('_with_pager',50)
                    ->defaults('_with_sort',['id'=>'desc'])
                    ->defaults('_view','console.access_control.roles')
                    ->name('.roles');

                Route::get('users', 'AccessControlController@users')
                    ->defaults('_with_pager',20)
                    ->defaults('_with_sort',['id'=>'desc'])
                    ->defaults('_view','console.access_control.users')
                    ->name('.users');


            });
    });
